const mongoose = require('mongoose')

const {
    Schema,
    model
} = mongoose

const userSchema = new Schema({
    name: {
        type: String,
        require: true
    },
    passward: {
        type: String,
        require: true,
        select: false
    },
    __v: {
        type: Number,
        select: false
    },
    avatar_url: {
        type: String
    },
    gender: {
        type: String,
        enum: ['male', 'famale'],
        default: 'male',
        required: true
    },
    headline: { // 一句话介绍
        type: String
    },
    locations: { // 居住地
        type: [{
            type: String
        }],
        select: false
    },
    business: { // 行业
        type: String,
        select: false
    },
    employments: { // 职业经历
        type: [{
            company: {
                type: String
            },
            job: {
                type: String
            }
        }],
        select: false
    },
    educations: { // 教育经历
        type: [{
            school: {
                type: String
            },
            major: {
                type: String
            },
            diploma: {
                type: Number,
                enum: ['1', '2', '3', '4', '5']
            },
            entrance_year: {
                type: Number
            },
            graduation_year: {
                type: Number
            }
        }],
        select: false
    },
    following: {
        type: [{
            type: Schema.Types.ObjectId,
            ref: 'User'
        }],
        select: false
    }

})

module.exports = model('User', userSchema)